import { WeaLocaleProvider,WeaTools} from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;
export default {
    addWindowFunc: () => {
        //下载附件
        window.downloadFile = (id,files,relateId,type,obj) => {
            WeaTools.callApi('/api/workrelate/common/viewDocFiled', 'POST', {id:id,relateId:relateId,type:type}).then((data) => {
                if (data.status) {
                    window.open("/weaver/weaver.file.FileDownload?fileid=" + files + "&download=1")
                }
              });
        }
        //打开附件
        window.openDoc = (id,relateId,type,obj) =>{
            WeaTools.callApi('/api/workrelate/common/viewDocFiled', 'POST', {id:id,relateId:relateId,type:type}).then((data) => {
                if (data.status) {
                    window.open("/spa/document/index.jsp?id=" + id + "#/main/document/detail")
                }
            });
        }
        //打开相应的链接
        window.openAppLink = (obj,id,type,relateId,model) =>{
            WeaTools.callApi('/api/workrelate/common/getRelateURL', 'GET').then((data) => {
                let mirror = {};
                if (data.status) {
                   mirror=data.result;      
                }else{
                    mirror = {
                        37: "/spa/document/index.jsp?id=",
                        7: "/spa/crm/mobx/index.html#/main/crm/customerView?customerId=",
                        152: "/spa/workflow/index_form.jsp#/main/workflow/req?requestid=",
                        8: "/spa/prj/index.html#/main/prj/projectCard?prjid=",
                        1:'/spa/hrm/index_mobx.html#/main/hrm/card/cardInfo/',
                    };
                }
                window.open(mirror[type]+id);
            });

        }
    }
};